package com.erp.service.impl;

import com.erp.bean.OrderState;
import com.erp.dao.OrderStateDao;
import com.erp.service.OrderStateService;
import com.erp.util.factroy.ObjectFactory;
import com.sun.xml.internal.bind.v2.model.core.ID;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author lpy
 * 订单状态业务逻辑实现类
 */
public class OrderStateServiceImpl implements OrderStateService {
    OrderStateDao orderStateDao = ObjectFactory.getDAOInstance("com.erp.dao.impl.OrderStateDaoImpl",OrderStateDao.class);

    @Override
    public boolean update(OrderState state) {
        boolean flag = false;
        try {
            flag = orderStateDao.update(state)>0;
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return flag;
    }

    @Override
    public OrderState findById(Integer sid) {
        OrderState orderState = null;
        try {
            orderState = orderStateDao.findById(sid);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return orderState;
    }

    @Override
    public List<OrderState> findAll() {
        List<OrderState> orderStates = new ArrayList<>();
        try {
            orderStates = orderStateDao.findAll();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return orderStates;
    }
}
